<?php 
$data = $mvc->getObject(BargainsService::BARGAINS);
$images = $mvc->getObject(UploadsService::PATH);
$bought = $mvc->getObject(BargainsService::BOUGHT_BARGAIN);
$boughtByUser = $mvc->getObject('count');
$error = $mvc->getObject(ContentController::ERROR);
$save = $mvc->getObject(ContentController::STATUS);
?>
<?php if(isset($data)&&count($data)>0&&$data!=NULL){?>
<div class="wrapWSearch">
	<div class="greyBox">
		<div class="viewBox viewBoxA">
			<div class="cT"><em class="cL"></em><em class="cR"></em></div>
			<div class="cL">
				<div class="cR">
					<div class="bodyBox">
						<h2><?php echo $data[BargainsService::BARGAIN_NAME]; ?></h2>
						<div class="unitDBlock">
							<div class="unitDLeft">
								<?php if (isset($images)&&$images!=NULL){ ?>
								<div class="unitImg">
									<ul>
										<?php foreach($images as $key => $image){ ?>
										<li><a href="<?php echo $image['path']?>" title=""><img src='<?php echo $image['path2']?>' ></a></li>
										<?php } ?>
									</ul>
								</div>
								<?php } ?>
							</div>
							<div class="unitDRight">
								<!-- start notification -->
								<?php if (isset($error)){?>
									<div class="itemWarning">
										<p><?php echo $error?></p>
									</div>
								<?php } ?>
								<?php if (isset($save)){?>
									<div class="itemOk">
										<p><?php echo $save?></p>
									</div>
								<?php } ?>
								<!-- end notification -->
								<div class="unitOrder">
									<div class="unitEqColumns">
										<dl>
											<dt>_i18n{Usual Price}:</dt>
											<dd class="itemPrice"><?php echo $data[BargainsService::USUAL_PRICE]; ?> &euro;</dd>
										</dl>
										<dl>
											<dt>_i18n{Bargain Price}:</dt>
											<dd class="itemPrice"><?php echo $data[BargainsService::BARGAIN_PRICE]; ?> &euro;</dd>
										</dl>
										<dl>
											<dt>_i18n{Discount}:</dt>
											<dd class="itemPrice"><?php echo $data[BargainsService::DISCOUNT]; ?>%</dd>
										</dl>
										<dl>
											<dt>_i18n{Available}:</dt>
											<dd class="itemPrice"><?php echo $data[BargainsService::NUMBER]; ?></dd>
										</dl>
									</div>
									<div class="unitEqColumns">
										<form method="post" action="view-bargain.html">
											<p>
												<input type="text" value="1" class="inpTxt" name="amount" />
												<input type="hidden" value="<?php echo $data[BargainsService::HASH]?>" name="id" />
												<button name="buy" value="1"><span><strong>_i18n{Buy}</strong></span></button>
											</p>
											<?php if(isset($boughtByUser) && $boughtByUser!=NULL){ ?>
												<p class="itemHistory">_i18n{You already bought}: <strong><?php echo count($boughtByUser); ?> _i18n{items}</strong></p>
											<?php } ?>
											<?php if (isset($bought)&&$bought!=NULL){ ?>
												<p class="itemHistory"><a href="#" title="">Show buyers</a></p>
											<?php } ?>
										</form>
									</div>
								</div>
								<dl>
									<dt>_i18n{Description}:</dt>
									<dd><?php echo htmlspecialchars_decode($data[BargainsService::BARGAIN_DESC]); ?></dd>
								</dl>
								<dl>
									<dt>_i18n{Remnant Time}:</dt>
									<dd><?php echo $data[BargainsService::TIME_LEFT]; ?></dd>
								</dl>
								<div class="unitLine"></div>
								<div class="unitEqColumns">
									<dl>
										<dt>_i18n{Category}:</dt>
										<dd><?php echo $data[CategoryService::CAT_NAME]; ?></dd>
										<dt>_i18n{SubCategory}:</dt>
										<dd><?php echo $data[SubCategoryService::SUBCAT_NAME]; ?></dd>
									</dl>
								</div>
								<div class="unitEqColumns">
									<dl>
										<dt>_i18n{Country}:</dt>
										<dd><?php echo $data[CountryService::COUNTRY_NAME]; ?></dd>
										<dt>_i18n{State}:</dt>
										<dd><?php echo $data[RegionService::REGION_NAME]; ?></dd>
										<dt>_i18n{City}:</dt>
										<dd><?php echo $data[BargainsService::CITY]; ?></dd>
										<dt>_i18n{Street}:</dt>
										<dd><?php echo $data[BargainsService::STREET]; ?></dd>
									</dl>
								</div>
								<div class="unitHistory">
									<?php if (isset($bought)&&$bought!=NULL){ ?>
										<p class="itemHistory"><a href="#" title="Hide history bids">Hide buyers</a></p>
										<table cellpadding="0" cellspacing="0">
											<tr>
												<th>_i18n{User}</th>
												<th class="itemLast">_i18n{Date}</th>
											</tr>
											<?php foreach($bought as $key => $value){ ?>
											<tr>
												<td><?php echo $value[UsersService::USERNAME]; ?></td>
												<td class="itemLast"><?php echo $value[BargainsService::BOUGHT_DATE];?></td>
											</tr>
											<?php } ?>
										</table>
									<?php } ?>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class="cB"><em class="cL"></em><em class="cR"></em></div>
		</div>
		<div class="lineHide"></div>
	</div>
</div>
<hr/>




<?php } else { ?>
_i18n{NO BARGAIN LIKE YOU WHANT}
<?php } ?>
